home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5787 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
  4. Subject: Re: Speed question here...
  5. Date: 20 Feb 1996 14:15:28 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4gdh60INN9l8@keats.ugrad.cs.ubc.ca>
  8. References: <4ftluh$1gkv@hearst.cac.psu.edu> <4fvjqnINN84p@keats.ugrad.cs.ubc.ca> <danpop.824472979@rscernix>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <danpop.824472979@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
  12.  >In <4fvjqnINN84p@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  13.  >
  14.  >>In article <4ftluh$1gkv@hearst.cac.psu.edu>,
  15.  >>William Koscho <koscho@wjk130.rh.psu.edu> wrote:
  16.  >>>I was curious as to how fast something like the 
  17.  >>>following would execute:
  18.  >>
  19.  >>I don't know? How fast can your compiler tell you that the program can't be
  20.  >>compiled?
  21.  >>
  22.  >>>    int x;
  23.  >>>    node *ptr;   ptr in linked list
  24.  >>>
  25.  >>>       for ( ptr = first_node; ptr != NULL; ptr = ptr.next ) {
  26.  >>
  27.  >>You don't dereference pointers by doing ptr.field. You use *(ptr).field, or,
  28.  >
  29.  >You misspelled (*ptr).field.  *(ptr).field is the same as *ptr.field and
  30.  >both are illegal because the dot operator has higher precedence.
  31.  
  32. Oops. (Moves vi cursor over '*', hits 'xp') You _have_ to write (*ptr).field
  33. (rare!) to mean ptr->field, _or_ *(*ptr)->field, to dereference member "field",
  34. assuming it's a pointer to non-void. 
  35.  
  36. It's interesting that  *(ptr).field  construct even _looks_ wrong, like
  37. something is fishy. The parentheses obviously don't buy you anything since
  38. they don't group any symbols, which is far from what I intended.  I apologize
  39. if I confused anyone.
  40. -- 
  41.  
  42.